package com.lala.service.impl;

import com.lala.entity.ClientComplaint;
import com.lala.dao.ClientComplaintDao;
import com.lala.service.ClientComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ClientComplaint)表服务实现类
 *
 * @author makejava
 * @since 2020-03-31 15:09:35
 */
@Service("clientComplaintService")
public class ClientComplaintServiceImpl implements ClientComplaintService {

    @Autowired
    private ClientComplaintDao clientComplaintDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ClientComplaint queryById(Integer id) {
        return this.clientComplaintDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ClientComplaint> queryAllByLimit(int offset, int limit) {
        return this.clientComplaintDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param clientComplaint 实例对象
     * @return 实例对象
     */
    @Override
    public ClientComplaint insert(ClientComplaint clientComplaint) {
        this.clientComplaintDao.insert(clientComplaint);
        return clientComplaint;
    }

    /**
     * 修改数据
     *
     * @param clientComplaint 实例对象
     * @return 实例对象
     */
    @Override
    public ClientComplaint update(ClientComplaint clientComplaint) {
        this.clientComplaintDao.update(clientComplaint);
        return this.queryById(clientComplaint.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.clientComplaintDao.deleteById(id) > 0;
    }


    @Override
    public void save(ClientComplaint complaint) {
        clientComplaintDao.insert(complaint);
    }
}